package com.gict.antifraudback.utils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

public class DownloadVideo {

    /**
     * 爬虫抓取链接超时时间，单位：毫秒
     */
    public static final int SPIDER_TIMEOUT = 10000;
    /**
     * 爬虫默认的userAgent
     */
    public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35";

    private static Map<String, String> map = new HashMap<>();

    static {
        map.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35");
        map.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
    }

    public static void main(String[] args) throws IOException {
        String chineseText = "三上悠亚";
        String url = "https://cdn.btlm.top:65533/s?word=";
        Document document = Jsoup.connect(url + URLEncoder.encode(chineseText, "UTF-8")).userAgent(USER_AGENT).ignoreContentType(true).headers(map).timeout(SPIDER_TIMEOUT).get();
        System.out.println(document);
    }
}
